<!-- 供应商列表 -->
<template>
	<div class="supplier-manange-list" v-loading="state.loading">
		<el-card shadow="hover" :body-style="{ paddingBottom: '0' }">
			<el-form class="text-right" :model="state.queryParams" ref="queryForm" :inline="true">
				<el-form-item>
					<el-button type="primary" icon="ele-Plus" @click="showAdd()"> 新增 </el-button>
				</el-form-item>
			</el-form>
		</el-card>
		<el-card class="full-table" shadow="hover" style="margin-top: 8px">
			<el-table :data="state.list" style="width: 100%" border>
				<el-table-column type="index" label="序号" width="55" align="center" />
				<el-table-column prop="name" label="姓名" align="center" show-overflow-tooltip />
				<el-table-column prop="providerName" label="供应商" align="center" show-overflow-tooltip />
				<el-table-column prop="cellPhone" label="电话号码" align="center" show-overflow-tooltip />
				<el-table-column prop="sex" label="性别" align="center" show-overflow-tooltip />
				<el-table-column prop="createrName" label="创建人" align="center" show-overflow-tooltip />
				<el-table-column prop="createTime" label="创建时间" align="center" show-overflow-tooltip />
				<el-table-column label="操作" width="150" align="center" fixed="right" show-overflow-tooltip>
					<template #default="scope">
						<el-button icon="el-icon-edit" size="small" text type="primary" @click="showAdd(scope.row)">编辑</el-button>
						<el-button icon="el-icon-delete" size="small" text type="primary" @click="deleteRow(scope.row)">删除</el-button>
					</template>
				</el-table-column>
			</el-table>
		</el-card>

		<addModal ref="addModalRef" @reload="handleQuery"></addModal>
	</div>
</template>

<script setup name="SupplierManage">
import { onMounted, reactive, ref } from 'vue';
import {useRouter, useRoute} from "vue-router";
import { ElMessage, ElMessageBox, ElNotification } from 'element-plus';
import {$get, $post} from '/@/utils/request';
import addModal from "./modules/addPersonModal.vue";

const router = useRouter();
const route = useRoute();
const addModalRef = ref();

const PUBLIC_PATH = import.meta.env.VITE_PUBLIC_PATH;
const state = reactive({
	loading: false,
	queryParams: {
		aaa: '',
		bbb: '',
	},
	list: [],
});

onMounted(async () => {
	handleQuery();
});

// 查询操作
const handleQuery = async () => {
	state.loading = true;
	var res = await $get('/personSrv/getpersonall');
	state.list = res.result || [];
	state.loading = false;
};

// 新增
const showAdd = (row) => {
	addModalRef.value.open(row);
}

// 删除
const deleteRow = row => {
	ElMessageBox.confirm('此操作将删除该人员信息，是否继续？', '提示', {
		type: 'warning'
	}).then(async () => {
		var res = await $post('/personSrv/removeproviderperson/'+row.id);
		ElNotification({
	    title: '提示',
	    message: '删除成功',
	    type: 'success',
	  })
	  // 更新列表
	  handleQuery();
	})
}

// 显示数据源
const showResource = (row) => {
	resourceModalRef.value.open(row.datasource);
};

</script>

<style lang="scss" scoped>
.supplier-manange-list {
	
}
</style>
